package com.example.viewpager2demo

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

class InnerPagerAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {
    override fun getItemCount(): Int = 3

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            0 -> MyStocksFragment.newInstance()
            1 -> MultiStocksFragment.newInstance()
            2 -> MainForceFragment.newInstance()
            else -> throw IllegalArgumentException("Invalid position $position")
        }
    }

    // 获取Fragment的tag
    fun getFragmentTag(position: Int): String {
        return "f$position"
    }
} 